import request from "@/utils/request";

// 获取商品详情
export function getGoodsDetailInfo(skuId) {
    return request.get(`/item/${skuId}`)
}

// 添加购物车
export function postAddShopCart(skuId,skuNum) {
    return request.post(`/cart/addToCart/${skuId}/${skuNum}`)
}

// 获取购物车列表
export function getShopCartList(){
    return request.get('/cart/cartList')
}

// 切换商品选中状态
export function getUpdateCartChrck(skuId,isChecked){
    return request.get(`/cart/checkCart/${skuId}/${isChecked}`)
}

// 批量修改购物车商品选中状态
export function postUpdateAllCartCheck(isChecked,skuIdList){
    return request.post(`/cart/batchCheckCart/${isChecked}`,skuIdList)
}

// 删除单个购物车商品
export function deleteSomeCart(skuId){
    return request.delete(`/cart/deleteCart/${skuId}`)
}

// 批量删除购物车已选中的商品
export function postDeleteAllCheckedCart(skuIdList){
    return request.post('/cart/batchDeleteCart',skuIdList)
}

// 注册
export function postRegister(userInfo){
    return request.post('/user/passport/register',userInfo)
}

// 获取验证码
export function getCode(phone){
    return request.get(`/user/passport/sendCode/${phone}`)
}

// 登录
export function postUserLogin(userInfo){
    return request.post('/user/passport/login',userInfo)
}

// 获取用户信息
export function getUserInfo(){
    return request.get('/user/passport/auth/getUserInfo')
}

// 退出登录
export function getLogout(){
    return request.get('/user/passport/logout')
}

// 获取交易信息
export function getTrade(){
    return request.get('/order/auth/trade')
}

// 获取用户地址-----只有测试账号有数据
export function getAddressList(){
    return request.get('user/userAddress/auth/findUserAddressList')
}

// 提交订单
export function postSubmitOrder(tradeNo,orderInfo){
    return request.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`,orderInfo)
}

// 获取支付订单信息
export function getOrderInfo(orderId){
    return request.get(`/payment/weixin/createNative/${orderId}`)
}

// 获取订单支付状态
export function getPayStatus(orderId){
    return request.get(`/payment/weixin/queryPayStatus/${orderId}`)
}

// 获取订单列表
export function getOrderList(page,limit){
    return request.get(`/order/auth/${page}/${limit}`)
}